using System.Collections.Generic;
using NUnit.Framework;
using ValidationFramework.Specifications;

namespace ValidationFramework.Specifications.Tests
{
	public class IsValidSpecTests
	{

		public class ClassNotIValidatable
		{
			[IsRequiredAttribute]
			public string PropertyToValidate { get; set; }
		}
		public class ClassIsIValidatable : IValidatable
		{
			public bool IsValid
			{
				get
				{
					return true;
				}
			}

			public IList<string> ErrorMessages
			{
				get
				{
					return null;
				}
			}
		}

		[TestFixture]
		public class IsEquivalentTo
		{
			[Test]
			public void Should_Be_Equivalent_When_Constructed_With_Same_Parameters()
			{
				var validator1 = new IsValidSpec();
				var validator2 = new IsValidSpec();
				Assert.IsTrue(validator1.IsEquivalentTo(validator2));
			}
			[Test]
			public void Should_NOT_Be_Equivalent_With_Different_TargetRulesets()
			{
				var validator1 = new IsValidSpec();
				var validator2 = new IsValidSpec() { TargetRuleSet = "NonDefaultTargetRuleSet" };
				Assert.IsFalse(validator1.IsEquivalentTo(validator2));
			}

			[Test]
			public void Should_NOT_Be_Equivalent_With_Different_UseTargetErrorMessages()
			{
				var validator1 = new IsValidSpec() { UseTargetErrorMessages = false };
				var validator2 = new IsValidSpec() { UseTargetErrorMessages = true };
				Assert.IsFalse(validator1.IsEquivalentTo(validator2));
			}

		}

		[TestFixture]
		public class RuleInterpretation
		{
			[Test]
			public void Should_Have_Interpretation()
			{
				var validator = new IsValidSpec();
			}
		}

		[TestFixture]
		public class Validate
		{
			[Test]
			public void Should_Be_Valid_When_Testing_Null_Value()
			{
				var validator = new IsValidSpec();
				Assert.IsTrue(validator.IsSatisfiedBy(null));
			}

			// TODO: Acctually test the validate method

		}

		// From the old code its not clear what types IsValidSpec can test.
		// In the validate method, if the type doesn't implement IValidatable then the facade will
		// be used.
		//[TestFixture]
		//public class CheckTypes
		//{
		//    [Test]
		//    public void Should_Be_Able_To_Test_The_Following()
		//    {
		//        var validator = new IsValidSpec();
		//        Assert.IsTrue(validator.CanBeSatisfiedBy(typeof(ClassIsIValidatable)));
		//    }

		//    [Test]
		////	[ExpectedException(typeof(ArgumentException), ExpectedMessage = "Member 'foo' must be a 'ValidationFramework.IValidatable' to be used for the ValidationFramework.ValidatableRule. Actual Type 'System.Int32'.\r\nParameter name: value")]
		//    public void Should_Not_Be_Able_To_Test_The_Following()
		//    {
		//        var validator = new IsValidSpec();

		//        Assert.IsFalse(validator.CanBeSatisfiedBy(typeof(int)));
		//    }
		//}

	}
}